package com.shanhai.log.controller;

import com.shanhai.log.common.aspect.OperatorLog;
import com.shanhai.log.common.enumeration.OperationType;
import org.springframework.boot.configurationprocessor.json.JSONException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

@RestController
public class ApiController {

    @OperatorLog(operationName = "操作说明", operationType = OperationType.OTHER)
    @RequestMapping(value = "/api", method = RequestMethod.GET)
    public HashMap<String, String> api(@RequestParam(value = "message", required = false) String message) throws JSONException {
        HashMap<String, String> resultMap = new HashMap<>();
        resultMap.put("ServiceName", "Shanhai-Log");
        resultMap.put("Version", "1.0");
        resultMap.put("Date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        resultMap.put("Message", message);
        return resultMap;
    }

}
